package com.android.lib.download.utils

import com.tencent.mmkv.MMKV

object Cache {

    init {
        MMKV.initialize(ContextHolder.application)
    }

    fun putString(key:String,value:String){
        var mmkv=MMKV.defaultMMKV()
        mmkv?.putString(key,value)
    }

    fun getString(key:String):String{
        var mmkv=MMKV.defaultMMKV()
        return mmkv?.getString(key,"")?:""
    }

    fun putInt(key: String,value:Int){
        var mmkv=MMKV.defaultMMKV()
        mmkv?.putInt(key,value)
    }

    fun getInt(key:String):Int{
        var mmkv=MMKV.defaultMMKV()
        return mmkv?.getInt(key,0)?:0
    }

    fun putLong(key: String,value:Long){
        var mmkv=MMKV.defaultMMKV()
        mmkv?.putLong(key,value)
    }

    fun getLong(key:String):Long{
        var mmkv=MMKV.defaultMMKV()
        return mmkv?.getLong(key,0)?:0
    }

    fun putBool(key: String,value:Boolean){
        var mmkv=MMKV.defaultMMKV()
        mmkv?.putBoolean(key,value)
    }

    fun getBool(key:String):Boolean{
        var mmkv=MMKV.defaultMMKV()
        return mmkv?.getBoolean(key,false)?:false
    }

    fun putFloat(key: String,value:Float){
        var mmkv=MMKV.defaultMMKV()
        mmkv?.putFloat(key,value)
    }

    fun getFloat(key:String):Float{
        var mmkv=MMKV.defaultMMKV()
        return mmkv?.getFloat(key,0f)?:0f
    }

    fun remove(key:String){
        var mmkv=MMKV.defaultMMKV()
        mmkv.remove(key)
    }

}